<?php
namespace App\Http\Controllers\Xcx\Mall;

use App\Service\Xcx\Mall\GoodsService;
use Illuminate\Http\Request;

class GoodsController extends BaseController
{
    //商品

    //分类列表
    public function cateList(Request $request)
    {
        $res = GoodsService::cateList();
        return $this->toJson(0, '', $res);
    }

    //列表
    public function getList(Request $request)
    {
        $pas['start'] = $request->post('page', 1);
        $pas['limit'] = $request->post('size', 6);
        $pas['cate_id'] = $request->post('cate_id', 0);
        $res = GoodsService::getList($pas);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson(0, '', $res['data'], $res['total']);
    }

    //详情
    public function getOne(Request $request)
    {
        $id = $request->post('id', 0);
        $uid = $request->post('uid', 0);
        $res = GoodsService::getOne($id, $uid);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson(0, '', $res['data']);
    }
}